//
//  ComplexPositionModel.m
//  u76ho
//
//  Created by m-air-01 on 16/1/21.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "ComplexPositionModel.h"

@implementation ComplexPositionModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        if ([key isEqualToString:@"errmsg"]) {
            NSArray * arr = value;
            NSMutableArray * mArr1 = [[NSMutableArray alloc]init];
            NSMutableArray * mArr2 = [[NSMutableArray alloc]init];
            
            for (int i = 0; i<arr.count; i++) {
                NSArray * array = arr[i];
                NSDictionary * dic = array[0];
                ComplexPositionDetailModel * model = [[ComplexPositionDetailModel alloc]initDic:dic];
                [mArr1 addObject:model];
                NSArray * lastArr = array[1];
                NSMutableArray * mArray = [[NSMutableArray alloc]init];
                for (int j = 0; j<lastArr.count; j++) {
                    NSDictionary * d = lastArr[j];
                    ComplexPositionDetailModel * m = [[ComplexPositionDetailModel alloc]initDic:d];
                    [mArray addObject:m];
                }
                [mArr2 addObject:mArray];
            }
            _firstArray = mArr1;
            _secondArray = mArr2;
        }
    }
    
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}
@end

//************************************
@implementation ComplexPositionDetailModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        [super setValue:value forKey:key];
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end